function [output] = ppm_demod_bin (size, input)
% Function for PPM Modulation.
% size: Size of PPM

len = length(input);
pic = log2(size);
% New Length of the PPM Demodulated Signal
nlen = (pic/size)*len;

output = [];
for i=1:(len/size)
    for j=0:size-1
        if (input(size*(i-1)+j+1) > 0.5)
            break;
        end
    end
    piece_output = de2bi(j,pic,'left-msb');
    output = [output piece_output];
end